/*
 * @Author: 徐建辰
 * @Date: 2022-05-25 10:51:27
 * @LastEditTime: 2022-05-25 10:57:37
 * @LastEditors: 徐建辰
 * @Description: 分页hook
 */
import {ref} from 'vue'
import paginationConfig from '@/config/pagination'

export default function usePagination() {
  const {size = 10} = paginationConfig
  const page = ref(paginationConfig.page)
  const pageSize = ref(size)

  /* 页数改变 */
  function handleSizeChange(currentSize) {
    pageSize.value = currentSize
  }
  /* 当前页改变 */
  function handlePageChange(curPage) {
    page.value = curPage
  }

  return {
    page, pageSize, 
    handleSizeChange, handlePageChange
  }
}